package sssta.org.picassodemo;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by cauchywei on 15/4/18.
 */
public class User {

    private boolean login;
    private String username;
    private String photo;
    private static User mUser;
    private static Context mContext;
    private SharedPreferences sp;


    public static void init(Context context){
        mContext = context;
    }

    private User(){

        sp = mContext.getSharedPreferences(Constants.SP_KEY,Context.MODE_PRIVATE);

        login = sp.getBoolean("login",false);


    }

    public static User getInstance(){

        if (mUser == null){
            mUser = new User();
        }

        return mUser;
    }

    public boolean isLogin() {
        return login;
    }

    public void setLogin(boolean login) {
        this.login = login;
        sp.edit().putBoolean("login",login).commit();
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }
}
